package cn.swu.Waimai.ui.fragment

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import cn.swu.Waimai.WaimaiApplication
import cn.swu.Waimai.R
import cn.swu.Waimai.center.LoginData
import cn.swu.Waimai.ui.activity.LoginActivity
import cn.swu.Waimai.ui.activity.MenuActivity
import kotlinx.android.synthetic.main.fragment_index.*


class IndexFragment : Fragment() {


    override fun onCreateView(

        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {

        return inflater.inflate(R.layout.fragment_index, container, false)
    }


    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        trivia_enter_menu.setOnClickListener {
            if (LoginData.LOGIN_STATUS == 0) {
                val intent = Intent(WaimaiApplication.context, LoginActivity::class.java)
                startActivity(intent)
            } else {
                val intent = Intent(WaimaiApplication.context, MenuActivity::class.java)
                intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
                startActivity(intent)
            }

        }
    }
}